package com.vvvtimes.demo.service;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.net.URLDecoder;
import cn.hutool.extra.qrcode.QrCodeUtil;
import com.vvvtimes.demo.common.dto.RestResponse;
import com.vvvtimes.demo.domain.dto.DecoderDTO;
import com.vvvtimes.demo.domain.dto.QueryDnsDTO;
import com.vvvtimes.demo.domain.dto.UrlDecoderDTO;
import com.vvvtimes.demo.domain.vo.AliDnsResolveVo;
import com.vvvtimes.demo.domain.vo.WeatherVo;
import com.vvvtimes.demo.util.OkHttp3ClientManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.charset.Charset;


@Slf4j
@Service
public class QueryService {

    public RestResponse<AliDnsResolveVo> dns(QueryDnsDTO queryDnsDTO) {
        RestResponse<AliDnsResolveVo> result =new RestResponse<>();
        String host = queryDnsDTO.getHost();
        String url = "http://dns.alidns.com/resolve?name="+host+"&type=1";
        try {
            AliDnsResolveVo aliDnsResolveVo = OkHttp3ClientManager.getInstance().sendGetObject(url, AliDnsResolveVo.class);
            if(aliDnsResolveVo!=null && aliDnsResolveVo.getStatus() == 0 ){
                result.setResult(aliDnsResolveVo);
            }
        } catch (IOException e) {
            e.printStackTrace();
            log.error(e.getMessage());
        }
        return result;
    }
}
